<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition>

        <p:dialog id="FlightEditDlg" widgetVar="FlightEditDialog" modal="true" resizable="false" appendToBody="true" header="#{bundle.EditFlightTitle}" closeOnEscape="true">

            <h:form id="FlightEditForm">

                <h:panelGroup id="display">
                    <p:panelGrid  columns="2" rendered="#{flightController.selected != null}">

                        <h:outputLabel value="#{bundle.EditFlightLabel_flightId}" for="flightId" />
                        <h:outputText id="flightId" value="#{flightController.selected.flightId}" />

                        <p:outputLabel value="#{bundle.EditFlightLabel_departureDate}" for="departureDate" />
                        <p:calendar id="departureDate" pattern="MM/dd/yyyy HH:mm:ss" value="#{flightController.selected.departureDate}" title="#{bundle.EditFlightTitle_departureDate}"  showOn="button"/>

                        <p:outputLabel value="#{bundle.EditFlightLabel_arrivalDate}" for="arrivalDate" />
                        <p:calendar id="arrivalDate" pattern="MM/dd/yyyy HH:mm:ss" value="#{flightController.selected.arrivalDate}" title="#{bundle.EditFlightTitle_arrivalDate}"  showOn="button"/>

                        <p:outputLabel value="#{bundle.EditFlightLabel_flightOrigin}" for="flightOrigin" />
                        <p:inputText id="flightOrigin" value="#{flightController.selected.flightOrigin}" title="#{bundle.EditFlightTitle_flightOrigin}" size="255" maxlength="255"/>

                        <p:outputLabel value="#{bundle.EditFlightLabel_flightDestination}" for="flightDestination" />
                        <p:inputText id="flightDestination" value="#{flightController.selected.flightDestination}" title="#{bundle.EditFlightTitle_flightDestination}" size="255" maxlength="255"/>

                        <p:outputLabel value="#{bundle.EditFlightLabel_cabinClass}" for="cabinClass" />
                        <p:inputText id="cabinClass" value="#{flightController.selected.cabinClass}" title="#{bundle.EditFlightTitle_cabinClass}" size="45" maxlength="45"/>

                        <p:outputLabel value="#{bundle.EditFlightLabel_price}" for="price" />
                        <p:inputText id="price" value="#{flightController.selected.price}" title="#{bundle.EditFlightTitle_price}"/>

                        <p:outputLabel value="#{bundle.EditFlightLabel_product}" for="product" />
                        <p:selectOneMenu id="product" value="#{flightController.selected.product}" required="true" requiredMessage="#{bundle.EditFlightRequiredMessage_product}" converter="productConverter">
                            <f:selectItem itemLabel="#{bundle.SelectOneMessage}"/>
                            <f:selectItems value="#{productController.items}"
                                           var="productItem"
                                           itemValue="#{productItem}"
                                           itemLabel="#{productItem.productId.toString()}"
                                           />

                        </p:selectOneMenu>
                    </p:panelGrid>
                    <p:commandButton actionListener="#{flightController.save}" value="#{bundle.Save}" update="display,:FlightListForm:datalist,:growl" oncomplete="handleSubmit(xhr,status,args,FlightEditDialog);"/>
                    <p:commandButton value="#{bundle.Cancel}" onclick="FlightEditDialog.hide()"/>
                </h:panelGroup>

            </h:form>

        </p:dialog>

    </ui:composition>

</html>
